/**
 * Copyright 2009 by Christian Scheid. This file is part of the switch eclipse plugin and is licensed under the GPL
 * version 3. Please refer to the URL http://www.gnu.org/licenses/gpl-3.0.html for details.
 */
package org.digitalsoul.switchplugin.actions.store;

import org.digitalsoul.switchplugin.actions.Action;
import org.digitalsoul.switchplugin.actions.ActionType;
import org.digitalsoul.switchplugin.model.ISwitchFile;

public class FileLoadAction extends Action {

    private final String fileKey;

    public FileLoadAction(String fileKey) {
        this.fileKey = fileKey;
    }

    @Override
    public ISwitchFile applyAction(ISwitchFile file) {
        ISwitchFile restoredFile = FileStore.getInstance().getFile(fileKey);
        if (restoredFile != null) {
            file = restoredFile;
        }
        return file;
    }

    @Override
    public ActionType getType() {
        return ActionType.FILE_LOAD;
    }

    @Override
    public String toString() {
        return fileKey;
    }
}
